package com.hp.attendance.service;

import com.hp.attendance.dao.CardDao;
import com.hp.attendance.entity.Card;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

public class CardService {
    private CardDao cardDao =new CardDao();
    private AttendanceService attendanceService=new AttendanceService();

    public void addCard(Card card) throws SQLException, IOException, ClassNotFoundException {
        cardDao.addCard(card);

    }
    public List<Card> queryCard() throws ClassNotFoundException, SQLException, InstantiationException, IllegalAccessException, IOException {
        List<Card> cards = cardDao.queryCard();
        return cards;
    }


    public void passCard(int id,int empNum,String date){
        try {
            cardDao.passCard(id);
            attendanceService.updateAtt(empNum,date);
        } catch (Exception throwables) {
            //回滚事务
            throwables.printStackTrace();
        }

    }
    public void delCard(int id) throws SQLException, IOException, ClassNotFoundException {
         cardDao.delCard(id);
    }
}
